home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_gdk-pixbuf.idb / usr / freeware / include / gdk-pixbuf-1.0 / gdk-pixbuf / gdk-pixbuf.h.z / gdk-pixbuf.h
C/C++ Source or Header  |  2002-07-08  |  9KB  |  267 lines

  1. /* GdkPixbuf library - Main header file
  2.  *
  3.  * Copyright (C) 1999 The Free Software Foundation
  4.  *
  5.  * Authors: Mark Crichton <crichton@gimp.org>
  6.  *          Miguel de Icaza <miguel@gnu.org>
  7.  *          Federico Mena-Quintero <federico@gimp.org>
  8.  *          Havoc Pennington <hp@redhat.com>
  9.  *
  10.  * This library is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU Library General Public
  12.  * License as published by the Free Software Foundation; either
  13.  * version 2 of the License, or (at your option) any later version.
  14.  *
  15.  * This library is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18.  * Library General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU Library General Public
  21.  * License along with this library; if not, write to the
  22.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  23.  * Boston, MA 02111-1307, USA.
  24.  */
  25.  
  26. #ifndef GDK_PIXBUF_H
  27. #define GDK_PIXBUF_H
  28.  
  29. #include <gdk/gdk.h>
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #include <gdk-pixbuf/gdk-pixbuf-features.h>
  36.  
  37.  
  38.  
  39. /* Color spaces; right now only RGB is supported */
  40. typedef enum {
  41.     GDK_COLORSPACE_RGB
  42. } GdkColorspace;
  43.  
  44. /* All of these are opaque structures */
  45. typedef struct _GdkPixbuf GdkPixbuf;
  46. typedef struct _GdkPixbufFrame GdkPixbufFrame;
  47. typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
  48.  
  49. /* Handler that must free the pixel array */
  50. typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data);
  51.  
  52. /* Handler for the last unref operation */
  53. typedef void (* GdkPixbufLastUnref) (GdkPixbuf *pixbuf, gpointer data);
  54.  
  55.  
  56.  
  57. /* Reference counting */
  58.  
  59. GdkPixbuf *gdk_pixbuf_ref      (GdkPixbuf *pixbuf);
  60. void       gdk_pixbuf_unref    (GdkPixbuf *pixbuf);
  61.  
  62. void       gdk_pixbuf_set_last_unref_handler (GdkPixbuf          *pixbuf,
  63.                           GdkPixbufLastUnref  last_unref_fn,
  64.                           gpointer            last_unref_fn_data);
  65.  
  66. void       gdk_pixbuf_finalize (GdkPixbuf *pixbuf);
  67.  
  68. /* GdkPixbuf accessors */
  69.  
  70. GdkColorspace gdk_pixbuf_get_colorspace      (const GdkPixbuf *pixbuf);
  71. int           gdk_pixbuf_get_n_channels      (const GdkPixbuf *pixbuf);
  72. gboolean      gdk_pixbuf_get_has_alpha       (const GdkPixbuf *pixbuf);
  73. int           gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf);
  74. guchar       *gdk_pixbuf_get_pixels          (const GdkPixbuf *pixbuf);
  75. int           gdk_pixbuf_get_width           (const GdkPixbuf *pixbuf);
  76. int           gdk_pixbuf_get_height          (const GdkPixbuf *pixbuf);
  77. int           gdk_pixbuf_get_rowstride       (const GdkPixbuf *pixbuf);
  78.  
  79.  
  80.  
  81. /* Create a blank pixbuf with an optimal rowstride and a new buffer */
  82. GdkPixbuf *gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample,
  83.                int width, int height);
  84.  
  85. /* Copy a pixbuf */
  86.  
  87. GdkPixbuf *gdk_pixbuf_copy (const GdkPixbuf *pixbuf);
  88.  
  89. /* Simple loading */
  90.  
  91. GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename);
  92.  
  93. GdkPixbuf *gdk_pixbuf_new_from_data (const guchar *data,
  94.                      GdkColorspace colorspace,
  95.                      gboolean has_alpha,
  96.                      int bits_per_sample,
  97.                      int width, int height,
  98.                      int rowstride,
  99.                      GdkPixbufDestroyNotify destroy_fn,
  100.                      gpointer destroy_fn_data);
  101.  
  102. GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const char **data);
  103.  
  104. /* Adding an alpha channel */
  105. GdkPixbuf *gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, gboolean substitute_color,
  106.                  guchar r, guchar g, guchar b);
  107.  
  108. /* Copy an area of a pixbuf onto another one */
  109. void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
  110.                int src_x, int src_y,
  111.                int width, int height,
  112.                GdkPixbuf *dest_pixbuf,
  113.                int dest_x, int dest_y);
  114.  
  115.  
  116.  
  117. /* Rendering to a drawable */
  118.  
  119. /* Alpha compositing mode */
  120. typedef enum {
  121.     GDK_PIXBUF_ALPHA_BILEVEL,
  122.     GDK_PIXBUF_ALPHA_FULL
  123. } GdkPixbufAlphaMode;
  124.  
  125. void gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
  126.                     int src_x, int src_y,
  127.                     int dest_x, int dest_y,
  128.                     int width, int height,
  129.                     int alpha_threshold);
  130.  
  131. void gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf,
  132.                     GdkDrawable *drawable, GdkGC *gc,
  133.                     int src_x, int src_y,
  134.                     int dest_x, int dest_y,
  135.                     int width, int height,
  136.                     GdkRgbDither dither,
  137.                     int x_dither, int y_dither);
  138.  
  139. void gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawable,
  140.                       int src_x, int src_y,
  141.                       int dest_x, int dest_y,
  142.                       int width, int height,
  143.                       GdkPixbufAlphaMode alpha_mode,
  144.                       int alpha_threshold,
  145.                       GdkRgbDither dither,
  146.                       int x_dither, int y_dither);
  147.  
  148. void gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf,
  149.                     GdkPixmap **pixmap_return, GdkBitmap **mask_return,
  150.                     int alpha_threshold);
  151.  
  152. /* Fetching a region from a drawable */
  153. GdkPixbuf *gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
  154.                      GdkDrawable *src, GdkColormap *cmap,
  155.                      int src_x, int src_y,
  156.                      int dest_x, int dest_y,
  157.                      int width, int height);
  158.  
  159.  
  160.  
  161. /* Scaling */
  162.  
  163. /* Interpolation modes */
  164. typedef enum {
  165.     GDK_INTERP_NEAREST,
  166.     GDK_INTERP_TILES,
  167.     GDK_INTERP_BILINEAR,
  168.     GDK_INTERP_HYPER
  169. } GdkInterpType;
  170.  
  171. void gdk_pixbuf_scale           (const GdkPixbuf *src,
  172.                  GdkPixbuf       *dest,
  173.                  int              dest_x,
  174.                  int              dest_y,
  175.                  int              dest_width,
  176.                  int              dest_height,
  177.                  double           offset_x,
  178.                  double           offset_y,
  179.                  double           scale_x,
  180.                  double           scale_y,
  181.                  GdkInterpType    interp_type);
  182. void gdk_pixbuf_composite       (const GdkPixbuf *src,
  183.                  GdkPixbuf       *dest,
  184.                  int              dest_x,
  185.                  int              dest_y,
  186.                  int              dest_width,
  187.                  int              dest_height,
  188.                  double           offset_x,
  189.                  double           offset_y,
  190.                  double           scale_x,
  191.                  double           scale_y,
  192.                  GdkInterpType    interp_type,
  193.                  int              overall_alpha);
  194. void gdk_pixbuf_composite_color (const GdkPixbuf *src,
  195.                  GdkPixbuf       *dest,
  196.                  int              dest_x,
  197.                  int              dest_y,
  198.                  int              dest_width,
  199.                  int              dest_height,
  200.                  double           offset_x,
  201.                  double           offset_y,
  202.                  double           scale_x,
  203.                  double           scale_y,
  204.                  GdkInterpType    interp_type,
  205.                  int              overall_alpha,
  206.                  int              check_x,
  207.                  int              check_y,
  208.                  int              check_size,
  209.                  guint32          color1,
  210.                  guint32          color2);
  211.  
  212. GdkPixbuf *gdk_pixbuf_scale_simple           (const GdkPixbuf *src,
  213.                           int              dest_width,
  214.                           int              dest_height,
  215.                           GdkInterpType    interp_type);
  216.  
  217. GdkPixbuf *gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
  218.                           int              dest_width,
  219.                           int              dest_height,
  220.                           GdkInterpType    interp_type,
  221.                           int              overall_alpha,
  222.                           int              check_size,
  223.                           guint32          color1,
  224.                           guint32          color2);
  225.  
  226.  
  227.  
  228. /* Animation support */
  229.  
  230. /* GIF-like animation overlay modes for frames */
  231. typedef enum {
  232.     GDK_PIXBUF_FRAME_RETAIN,
  233.     GDK_PIXBUF_FRAME_DISPOSE,
  234.     GDK_PIXBUF_FRAME_REVERT
  235. } GdkPixbufFrameAction;
  236.  
  237. GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file   (const char         *filename);
  238.  
  239. GdkPixbufAnimation *gdk_pixbuf_animation_ref             (GdkPixbufAnimation *animation);
  240. void                gdk_pixbuf_animation_unref           (GdkPixbufAnimation *animation);
  241.  
  242. int                 gdk_pixbuf_animation_get_width       (GdkPixbufAnimation *animation);
  243. int                 gdk_pixbuf_animation_get_height      (GdkPixbufAnimation *animation);
  244. GList              *gdk_pixbuf_animation_get_frames      (GdkPixbufAnimation *animation);
  245. int                 gdk_pixbuf_animation_get_num_frames  (GdkPixbufAnimation *animation);
  246.  
  247. /* Frame accessors */
  248.  
  249. GdkPixbuf           *gdk_pixbuf_frame_get_pixbuf     (GdkPixbufFrame *frame);
  250. int                  gdk_pixbuf_frame_get_x_offset   (GdkPixbufFrame *frame);
  251. int                  gdk_pixbuf_frame_get_y_offset   (GdkPixbufFrame *frame);
  252. int                  gdk_pixbuf_frame_get_delay_time (GdkPixbufFrame *frame);
  253. GdkPixbufFrameAction gdk_pixbuf_frame_get_action     (GdkPixbufFrame *frame);
  254.  
  255.  
  256. /* General (presently empty) initialization hooks, primarily for gnome-libs */
  257. void gdk_pixbuf_preinit  (gpointer app, gpointer modinfo);
  258. void gdk_pixbuf_postinit (gpointer app, gpointer modinfo);
  259.  
  260.  
  261.  
  262. #ifdef __cplusplus
  263. }
  264. #endif
  265.  
  266. #endif
  267.